<template>
  <div>
    <search-bar placeHolder="请输入公司名称/负责人"
                @handleSearch="init" />
    <!-- search end -->
    <div class="box">
      <v-table :tableData='tableData.data'
               :tableLabel="tableLabel"
               @handleExports="handleExports"
               v-loading="loading" />
      <!-- 分页器 -->
      <ubi-paging :page.sync="page"
                  :pageSize.sync="pageSize"
                  style="position:absolute;bottom:0;"
                  :pageCount="tableData.rows " />
    </div>
  </div>
</template>

<script>

import ubiPaging from '@/views/UBI/common/ubi-data-pagination'
export default {
  name: "deviceMail",
  components: {
    ubiPaging
  },
  data () {
    return {
      page: 1,
      activeDate: '', //选择日期
      pageSize: 8, //每页显示多少条数据
      searchkey: '', //搜索关键字
      tableData: {},//表格数据
      tableLabel: [
        {
          label: '收件人',
          prop: 'man'
        },
        {
          label: '联系电话',
          prop: 'phone'
        },
        {
          label: '收货地址',
          prop: 'address'
        },
        {
          label: '支付时间',
          prop: 'time'
        },
        {
          label: '导出时间',
          prop: 'hair_time'
        },
        {
          label: '是否导出',
          EXPORT: true,
          prop: 'status',
          methodName: 'handleExports',
          policyStatus: ["未导出", "已导出"]
        }
      ],//表格数据对应的标题
      loading: false

    }
  },
  methods: {
    async init (search = this.searchkey) {
      this.loading = true;
      const paramsStr = Object.assign(search,{page: this.page,pageSize: this.pageSize})
      let res = await this.api.deviceMail(paramsStr).then(res => res)
      this.tableData = res.data;
      this.loading = false;
    },
    async handleExports () {
      this.$confirm('', {
        title: "确认导出吗？",
        message: '确认后若出现提示弹框请点击保存, 否则将会丢失文件',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        window.location.href = `${process.env.VUE_APP_URL}manage/Login/order`
        this.init()
      }).catch(() => {
      })
    },
    digui (n) {
      if (n == 1) return 1;
      return n * this.digui(n - 1)
    }
  },
  mounted () {
    this.init();
  }
}
</script>

<style scoped>
.box {
  min-height:81vh;
  position:relative;
  padding-bottom:40px;
  box-sizing:border-box;
}
</style>
